package com.applet.message.controller;


import com.applet.code.enums.SmsTypeEnum;
import com.applet.message.sms.service.SmsService;
import com.applet.message.util.ResultResponse;

import com.applet.code.vo.SmsReturnVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/sms")
public class SmsController {
    private Logger logger = LoggerFactory.getLogger(SmsController.class);
    @Resource
    private SmsService smsService;

    /**
     * 发送普通短信
     *
     * @param type  短信类型 1国内，2国外
     * @param phone 多个手机号码使用英文逗号分隔
     * @return
     */
    @RequestMapping(value = "/sendSms")
    public ResultResponse sendSms(Integer type, String phone) {
        logger.info("sendSms type:{},msg:{},phone:{}");
        if (type == SmsTypeEnum.TYPE_1.getType()) {
            SmsReturnVo result = smsService.sendSms(SmsTypeEnum.TYPE_1, phone);
            return new ResultResponse(true, result);
        }
        return new ResultResponse(false, null);


    }

}
